package org.stu.tp.testCases.BWList;

import org.stu.tp.core.BaseSac;
import org.stu.tp.core.DefaultAjaxSelenium;
import org.stu.tp.util.GetProperties;

public class BWListSac extends BaseSac {

	/**
	 * Click the Telephone book at the left panel
	 * 
	 * @param selenium
	 */
	public void clickAccessBWList(DefaultAjaxSelenium selenium) {
		selenium.clickAt("wb_0_Item_5", "");
		this.waitForPageToLoad(selenium);
	}
	/**
	 * Login with the specify account and access to contact book page.
	 * @param selenium
	 * @param userName
	 * @param password
	 */
	public void loginAndAccessBWList(DefaultAjaxSelenium selenium,String userName,String password){
		this.login(selenium, userName, password);
		this.clickAccessBWList(selenium);
	}
	
	/**
	 * Login with the default account and access to contact book page.
	 * @param selenium
	 */
	public void loginAndAccessBWList(DefaultAjaxSelenium selenium){
		loginAndAccessBWList(selenium,GetProperties.getUserName(), GetProperties.getPassword());
	}
	
	public void setPhone(DefaultAjaxSelenium selenium,String phone){
		selenium.type("ctl00_content_txtPhoneNum", phone);
		}
	
	public void getPhone(DefaultAjaxSelenium selenium){
		selenium.getText("ctl00_content_txtPhoneNum");
		}
	
	public void checkSetEffective(DefaultAjaxSelenium selenium){
		selenium.check("ctl00_content_chkInforce");	
	}
	public void unCheckSetEffective(DefaultAjaxSelenium selenium){
		selenium.uncheck("ctl00_content_chkInforce");	
	}
	public boolean isCheckSetEffective(DefaultAjaxSelenium selenium){
		return selenium.isChecked("ctl00_content_chkInforce");	
	}
	
	
	public void clickSaveButton(DefaultAjaxSelenium selenium){
		selenium.click("ctl00_content_btnSave");
	}
	
	public void clickCancelButton(DefaultAjaxSelenium selenium){
		selenium.click("ctl00_content_btnCancel");
	}
	
	/**
	 * Select the frame to type the phone number
	 * @param selenium
	 */
	public void selectSetPhoneWindow(DefaultAjaxSelenium selenium){
		selenium.selectFrame("index=3");
	}

	/**
	 * Select the frame to type the phone number
	 * @param selenium
	 */
	public void selectMainWindow(DefaultAjaxSelenium selenium){
		selenium.selectWindow("name=Doc_Frame");
	}
	
//	#########################Black List###################
	public void checkUseBL(DefaultAjaxSelenium selenium){
		selenium.check("ctl00_content_chkIsUseBList");
	}
	
	
	
//	Action
	public void clickAddButtonBL(DefaultAjaxSelenium selenium){
		selenium.click("//table[@id='dataGrid']//input");
	}
	/**
	 * @param selenium
	 * @param index: the index of the phone
	 */
	public void clickEditButtonBL(DefaultAjaxSelenium selenium,Integer index){
		index=index+2;
		selenium.click("//table[@id='dataGrid']//tr["+index.toString()+"]//a[1]");
	}
	
	/**
	 * @param selenium
	 * @param index: the index of the phone
	 */
	public void clickDeleteButtonBL(DefaultAjaxSelenium selenium,Integer index){
		index=index+2;
		selenium.click("//table[@id='dataGrid']//tr["+index.toString()+"]//a[2]");
	}

	
//	#########################While List###################
	public void checkUseWL(DefaultAjaxSelenium selenium){
		selenium.check("ctl00_content_chkIsUseWList");
	}
	
	
	
//	Action
	public void clickAddButtonWL(DefaultAjaxSelenium selenium){
		selenium.click("//table[@id='dataGrid2']//input");
	}
	
	/**
	 * @param selenium
	 * @param index: the index of the phone
	 */
	public void clickEditButtonWL(DefaultAjaxSelenium selenium,Integer index){
		index=index+2;
		selenium.click("//table[@id='dataGrid2']//tr["+index.toString()+"]//a[1]");
	}
	
	/**
	 * @param selenium
	 * @param index: the index of the phone
	 */
	public void clickDeleteButtonWL(DefaultAjaxSelenium selenium,Integer index){
		index=index+2;
		selenium.click("//table[@id='dataGrid2']//tr["+index.toString()+"]//a[2]");
	}

	
	
	
	
	
	
	
	
}
